package com.zhengdongzulin.zuke.app.main.apartment.sign

import com.lxj.androidktx.core.*
import com.zhengdongzulin.zuke.R
import com.zhengdongzulin.zuke.app.data.ContractListData
import com.zhengdongzulin.zuke.base.*
import com.zhengdongzulin.zuke.databinding.ZkActivitySign2Binding
import com.zhengdongzulin.zuke.ext.start

class ZKSign2Activity : BaseActivity<SignVm, ZkActivitySign2Binding>() {

    var mData = mutableListOf<ContractListData>()

    override fun getLayoutResId(): Int = R.layout.zk_activity_sign2

    override fun initVM(): SignVm = getVM(SignVm::class.java)

    override fun initView() {
        setTitleContent("账单明细")
    }

    override fun initData() {
        mViewModel.bill_details(
            houseId = intent.getStringExtra("houseId")!!,
            rentTypeId = intent.getStringExtra("rentTypeId")!!,
            payTypeId = intent.getStringExtra("payTypeId")!!,
            startDate = intent.getStringExtra("startDate2")!!
        )
    }

    override fun initListener() {
        mView.next.setOnClickListener {
            intent.start(this@ZKSign2Activity, ZKSign3Activity::class.java)
        }
    }

    override fun startObserve() {

        mViewModel.bill_details.observe(this, androidx.lifecycle.Observer {
            mView.run {
                tvDoorName.text = "${it.rentTime}"
                tvArea.text = "${it.startDate}\u0020至\u0020${it.endDate}"
                tvSign2RentTime.text = "${it.startDate}\u0020至\u0020${it.firstEndDate}"
                tvSign2PropertyTime.text = "${it.startDate}\u0020至\u0020${it.firstEndDate}"
                contractTotalMoney.text = "${it.contractTotalMoney}元"
                payType.text = "${it.payType}"
                tvSign2RentContent.text = "${it.rentMoney}元"
                tvSign2RentDesc.text = "定金已扣${it.earnestMoney}元"
                tvSign2PropertyContent.text = "${it.propertyMoney}元"
                price.text = "${it.depositMoney}元"
            }
        })
        mViewModel.bill_details.state.observe(
            this,
            getObserver(mViewModel.bill_details)
        )
    }

}